# Recipe file for pwgen.
#
# Maintainers: (C) 2016,2017 Mateus P. Rodrigues, mprodrigues@dragora.org.
#
# Under the terms of the GNU General Public License.

program=pwgen
version=2.07
release=1

description="
Make pronouceble passwords
"

homepage=https://github.com/jbernard/pwgen
license=GPLv2

tarname=${program}_${version}.orig.tar.gz

# Remote source(s)
fetch=http://http.debian.net/debian/pool/main/p/pwgen/$tarname

# Parallel jobs for the compiler
jobs=1

build() {
    unpack "${tardir}/$tarname"

    cd "$srcdir"

    ./configure CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS -static" \
    $configure_args \
    --infodir=$infodir \
    --mandir=$mandir \
    --docdir=$docdir \
    --build="$(cc -dumpmachine)"

    make -j${jobs}
    make -j${jobs} install DESTDIR="$destdir"

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 '{}' +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

}
